package projbd;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Similarity {
    
    private static Connection connection = null;
    
    public static void runSQL(String sql) {
        
        try {
            Statement statement = connection.createStatement();
            statement.execute(sql);
            statement.executeBatch();
            
        } catch (SQLException ex) {
            Logger.getLogger(OrderSizeNumSchemeXMLParser.class.getName()).log(Level.SEVERE, null, ex);
        }     
    }
    
    
    public static void main(String[] args) {
        
        /* BD Connection */
        
        try {           
            Class.forName("org.postgresql.Driver");         
            connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/projbd", "postgres", "srx3325");
            if(connection != null) {
                System.out.println("CONNECTED !!!");
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ProjBD.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(ProjBD.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        for(int i = 1; i < 99; i++) {
            runSQL("INSERT INTO n ( i ) VALUES ( " + i + " );");
        }
        
        
        /* BD Close Connection */
        
        try {
            connection.close();
        } catch (SQLException ex) {
            Logger.getLogger(Similarity.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
}
